<h1></h1>
<script>
const h = document.querySelector('h1')
const key = 'counter'
let count = parseInt(localStorage.getItem(key) || 0)

const render = () => {
  count += 1
  h.innerText = count
  localStorage.setItem(key, count)
}
document.documentElement.onclick = render
render()
</script>